//
//  NavigationViewController.m
//  易房宝测试
//
//  Created by chenliang on 14-8-14.
//  Copyright (c) 2014年 chenliang. All rights reserved.
//

#import "NavigationViewController.h"

@interface NavigationViewController ()

@end

@implementation NavigationViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

#pragma mark 一个类只会调用一次

+ (void)initialize

{
    // 1.取出设置主题的对象
    
    UINavigationBar *navBar = [UINavigationBar appearance];
    
    // 2.设置导航栏的背景图片
    
    if ([self isIOS7]) { // iOS7
        
        navBar.tintColor = [UIColor whiteColor];
        
    } else { // 非iOS7
        
        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;
    }
    
    //NSLog(@"navFrame: %@",NSStringFromCGRect(navBar.frame));
    
    // 3.标题
    
    [navBar setTitleTextAttributes:@{
                                     
    NSForegroundColorAttributeName : [UIColor whiteColor]
                                     
    }];
    
}

+(BOOL) isIOS7{
    
    static NSUInteger _deviceSystemMajorVersion = -1;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken,^{
        _deviceSystemMajorVersion = [[[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."] objectAtIndex:0] intValue];
    });
    return (_deviceSystemMajorVersion >= 7);
}

#pragma mark 控制状态栏的样式

- (UIStatusBarStyle)preferredStatusBarStyle

{
    return UIStatusBarStyleDefault;//黑色
//     return UIStatusBarStyleLightContent;
    
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
